var baseUrl = '/mobileManage/action/'

var map0 = new Map();
map0.set("1", "最高管理员");
map0.set("2", "公司管理员");
map0.set("3", "公司老师");
map0.set("4", "代理");


map0.set("5", "招生老师");
map0.set("10", "搜题老师");

var map1 = new Map();
map1.set("0", "全部学生");
map1.set("1", "黑龙江省全日制大专");
map1.set("2", "成人教育");
map1.set("3", "自学考试");
map1.set("4", "计算机");
map1.set("5", "远程教育");
map1.set("6", "资格证书");
map1.set("7", "职称证书");
map1.set("8", "研究生");
map1.set("9", "医学");
map1.set("10", "国家开放大学");
map1.set("11", "省外全日制大专");
map1.set("12", "中专学历");
map1.set("13", "技能证书");
//添加学生信息页面map1
function map1Function() {
    html = ""
    htmlleft = ""
    map1.forEach(function (item, index, arr) {
        html += '<option value="' + index + '">' + item + '</option>';
        htmlleft += '<dd><a data-url="page/main.html" onclick="condition(this,' + index + ');" class="text-center">' + item + '</a></dd>';
    });
    $(".educationType").html(html);
    $(".educationTypehtmlleft").html(htmlleft);
}

/*根据map1用数字获取文字*/
function mapWrite(num) {
    var write;
    map1.forEach(function (item, index, arr) {
        if (num == index) {
            write = item;
        }
    });
    return write;
}

var map2 = new Map();
map2.set("0", "未缴费");
map2.set("1", "已缴费");

var map3 = new Map();
map3.set("1", "已提交");
map3.set("0", "未提交");

var map4 = new Map();
map4.set("1", "已报名");
map4.set("0", "未报名");

var map5 = new Map();
map5.set("1", "教育机构");
map5.set("2", "中专学校");
map5.set("3", "大专学校");
/*成人页面需要*/
var map6 = new Map();
map6.set("0", "请选择");
map6.set("1", "成人教育");
map6.set("2", "自学考试");
map6.set("3", "网络教育");
map6.set("4", "研究生");
/*成人页面需要 主页也需要*/
var map7 = new Map();
map7.set("0", "请选择");
map7.set("1", "高起专");
map7.set("2", "专升本");
map7.set("3", "高起本");
map7.set("4", "研究生");
map7.set("5", "二学历");
map7.set("6", "中专");
map7.set("7", "资格证书");

/**第二学历页面使用 */
var map8 = new Map();
map8.set("0", "请选择");
map8.set("1", "高起专");
map8.set("2", "专升本");
map8.set("3", "高起本");
map8.set("4", "研究生");
map8.set("5", "二学历");
map8.set("6", "中专");
map8.set("7", "在职");
map8.set("8", "全日制");

//添加学生信息页面map7
function map7Function() {
    html = ""
    map7.forEach(function (item, index, arr) {
        html += '<option value="' + index + '">' + item + '</option>';

    });
    $("#cengci").html(html);

}
/*根据map7用数字获取文字*/
function map7Write(num) {
    var write;
    map7.forEach(function (item, index, arr) {
        if (num == index) {
            write = item;
        }
    });
    return write;
}
//1:单选,2:多选,3:填空,4:判断,5:简答
var map9 = new Map();
map9.set("0", "请选择");
map9.set("1", "单选题");
map9.set("2", "多选题");
map9.set("3", "填空题");
map9.set("4", "判断题");
map9.set("5", "简答题");

var education = new Map();
education.set("1", "高中生");
education.set("2", "中专生");
education.set("3", "社会青年");
education.set("4", "大专生");
education.set("5", "本科生");

var kind = new Map();
kind.set("1", "退伍军人");
kind.set("2", "在校大学生");
kind.set("3", "在校高中生");
kind.set("4", "社会青年");

function mapred(num) {
    if (num > 0) {
        return "style='color:red'"
    }
}

//获取服务器时间
function getTime() {
    var date = new Date();
    //年
    var year = date.getFullYear();
    //月
    var month = date.getMonth() + 1;
    month = month < 10 ? "0" + month : month;
    //日
    var day = date.getDate();
    day = day < 10 ? "0" + day : day;
    //时
    var hh = date.getHours();
    hh = hh < 10 ? "0" + hh : hh;
    //分
    var mm = date.getMinutes();
    mm = mm < 10 ? "0" + mm : mm;
    //秒
    var ss = date.getSeconds();
    ss = ss < 10 ? "0" + ss : ss;
    var rq = year + "年" + month + "月" + day + "日" + " " + hh + ":" + mm + ":" + ss;
    return rq;
}

function batch(checkStatus) {
    var checkQuery = [];
    for (let i = 0; i < checkStatus.data.length; i++) {
        checkQuery.push(checkStatus.data[i].id);
    }
    return checkQuery.join(',');
}

//加载公司下拉
function loadCompanyList(form, $) {
    $.ajax({
        url: baseUrl + "company/getCompanyList.php",
        type: "GET",
        dataType: "JSON",
        success: function (res) {
            if (res.data) {
                res.data.forEach(company => {
                    $('#company').append(new Option(company.companyName, company.id, true))
                })
                form.render();
            }
        }
    })
}

//加载层次类型下拉
function loadSelect(form, $, url, selector, edit) {
    return new Promise((resolve, reject) => {
        $.ajax({
            url: baseUrl + url,
            type: "GET",
            dataType: "JSON",
            success: function (res) {
                if (res.data) {
                    if (edit) {
                        resolve(res.data);
                    } else {
                        $(selector).append(new Option("请选择", "", true))
                        res.data.forEach(item => {
                            $(selector).append(new Option(item.name, item.id, true))
                        })
                        form.render();
                    }
                }
            }
        })
    })
}

/**
         * 修改属性名为
         * @param {旧的参数名} oldVal
         * @param {新的参数名} newVal
         * @param {arr} 对象数组
         */
function updatePropertyName(oldVal, newVal, arr) {
    for (let i in arr) {
        for (let j in arr[i]) {
            if (j == oldVal) {
                arr[i][newVal] = arr[i][j]//修改属性名为newVal
                delete arr[i][oldVal]//删除oldVal
            }
        }
    }
}